<?php defined('IN_LK') or die('Access Denied');?>
<?php include self::admin_t('header');?>

<div id="login_error" class="message msg">
<form action="?m=admin&c=admin_log" method="post">
用户名 <input type="text" class="input" name="info[username]" id="username" value="<?php echo $username;?>" size="13" /> 
时间 <?php echo form::input_date('info[start_time]', $start_time);?> 至 
<?php echo form::input_date('info[end_time]', $end_time, 1, 0);?> 
<input type="submit" class="btn" name="dosubmit" id="dosubmit" value="搜索" />
</form>
</div>
<div class="table-list">
  <table width="100%" cellspacing="0">
    <thead>
      <tr>
        <th width="20"><input type="checkbox" id="logid" value="" onclick="select_all(this.id, 'logid[]')" title="全选/取消" /></th>
        <th width="80">序号</th>
        <th align="left" width="12%">用户名</th>
        <th  width="">操作</th>
        <th  width="18%">IP</th>
        <th width="20%">时间</th>
      </tr>
    </thead>
    <tbody>
      <?php if($logs){foreach($logs as $log){?>
      <tr>
        <td align="center"><input type="checkbox" name="logid[]" value="<?php echo $log['logid'];?>" /></td>
        <td align="center"><?php echo $log['logid'];?></td>
        <td><?php echo $log['username'];?></td>
        <td><?php echo $log['query'];?></td>
        <td align="center"><?php echo $log['ip'];?></td>
        <td align="center"><?php echo $log['time'];?></td>
      </tr>
      <?php }}else{?>
      <tr>
      	<td colspan="6" align="center">暂无数据</td>
      </tr>
      <?php }?>
    </tbody>
  </table>
  <div class="bot"> <a href="javascript:void(0);" onclick="select_all('all', 'logid[]')">全选</a> / <a href="javascript:void(0);" onclick="select_all('none', 'logid[]')">取消</a>
    <input type="button" class="btn" name="dosubmit" id="dosubmit" value="删除选中" onclick="delete_check('logid[]')" />
    <input type="button" class="btn" name="delete" id="delete" value="删除一月前数据" onclick="delete_month()" />
  </div>
  <?php echo $page_nav;?> </div>
<?php include self::admin_t('footer');?>
<script type="text/javascript">
function delete_month()
{
	window.top.art.dialog(
	{
		title: '删除一月前数据',
		content:'你确定要删除这些日志吗？',
		fixed:true,
		id:'delete'
	},
	function ()
	{
		$.ajax(
		{
			type : 'GET',
			url : '?m=admin&c=admin_log&a=delete&month=1',
			success:function(data)
			{
				parent.main.location.reload();
			}
		});
	},
	function ()
	{
		window.top.art.dialog({id:'delete'}).close();
	});
}
function delete_check(name)
{
	var logid = '';
	$('input[name="' + name + '"]').each(function()
	{
		if(this.checked)
		{
			logid += this.value + ',';
		}
	});
	if(logid == '')
	{
		alert('请至少选择一项');
		return false;
	}
	window.top.art.dialog(
	{
		title:'删除日志',
		content: '你确定要删除这些日志吗？',
		fixed:true,
		id:'delete_check'
	},
	function ()
	{
		$.ajax(
		{
			type: "POST",
			url: "?m=admin&c=admin_log&a=delete",
			data: "logid=" + logid,
			success: function(data)
			{
				parent.main.location.reload();
			}
		});
	},
	function (){window.top.art.dialog({id:'delete_check'}).close();});
}
</script>
